//! Good-MITM 被动扫描引擎
//! 
//! 基于MITM流量进行安全检测的被动扫描系统，不发起主动探测，只分析经过的流量。

pub mod event;
pub mod dedup;
pub mod processor;
pub mod matcher;
pub mod alert;
pub mod config;
pub mod storage;

// 暂时移除engine模块的引用
// pub use engine::PassiveScanEngine;
pub use event::{HttpEvent, EventType, EventMetadata};
pub use dedup::{DedupManager, DedupConfig};
pub use processor::{EventProcessor, WorkerPool, ProcessorConfig};
pub use matcher::{MatchTarget, RegexMatcher, RegexRule, RuleMatcher, ScanResult, Severity};
pub use alert::{AlertManager, AlertChannel};
pub use config::ScanConfig;
pub use storage::{StorageBackend, MemoryStorage, FileStorage};

#[cfg(feature = "database")]
pub use storage::{DatabaseStorage, SqliteStorage};

/// 被动扫描引擎错误类型
#[derive(thiserror::Error, Debug)]
pub enum ScanError {
    #[error("事件处理错误: {0}")]
    EventError(String),
    #[error("去重错误: {0}")]
    DedupError(String),
    #[error("规则匹配错误: {0}")]
    MatcherError(String),
    #[error("存储错误: {0}")]
    StorageError(String),
    #[error("配置错误: {0}")]
    ConfigError(String),
    #[error("IO错误: {0}")]
    IoError(#[from] std::io::Error),
    #[error("序列化错误: {0}")]
    SerializationError(#[from] serde_json::Error),
    #[error("数据库错误: {0}")]
    #[cfg(feature = "database")]
    DatabaseError(#[from] sqlx::Error),
}

/// 被动扫描引擎结果类型
pub type GenericScanResult<T> = Result<T, ScanError>;